package com.caojing.syby.ui.home;

import com.caojing.syby.bean.home.HomeGvBean;
import com.caojing.syby.bean.home.HomeTodayBean;
import com.caojing.syby.bean.home.HomeVpBean;
import com.caojing.syby.httputils.HttpUtils;

import java.util.HashMap;
import java.util.List;

/**
 * Created by CaoJing on 2016/10/5.
 */
public class HomePresenter implements HomeContract.Presenter {

    private HomeContract.Model model;
    private HomeContract.View view;

    public HomePresenter(HomeContract.View view) {
        this.view = view;
        this.model = new HomeModel();
    }
    /*加载首页viewpager数据*/
    @Override
    public void initVpData() {
        model.getVpBean(new HttpUtils.HttpCallBack<HomeVpBean>() {
            @Override
            public void onSucess(HomeVpBean homeVpBean) {
                view.onSuccessGetVp(homeVpBean);
            }
            @Override
            public void onFail() {
                view.onFailGetVp("vp网络连接错误");
            }
        });
    }
    /*加载首页中间视图数据*/
    @Override
    public void initTodayData() {
        model.getTodayBean(new HttpUtils.HttpCallBack<List<HomeTodayBean>>() {
            @Override
            public void onSucess(List<HomeTodayBean> list) {
                view.onSuccessGetToday(list);
            }
            @Override
            public void onFail() {
                view.onFailGetToday("today网络连接错误");
            }
        });
    }
    /*加载首页gridview数据*/
    @Override
    public void initGvData(HashMap<String, String> params) {
        model.getGvBean(params, new HttpUtils.HttpCallBack<HomeGvBean>() {
            @Override
            public void onSucess(HomeGvBean homeGvBean) {
                view.onSuccessGetGv(homeGvBean);
            }
            @Override
            public void onFail() {
                view.onFailGetGv("Gv网络连接错误");
            }
        });
    }
}
